<?php

namespace app\module\api\controllers;
use yii\filters\auth\HttpBearerAuth;
use yii\filters\Cors;
use yii\rest\ActiveController;

/**
 * @project kkzc
 * @date 2015-7-3
 * @author xialei <xialeistudio@gmail.com>
 */
class BaseController extends ActiveController
{
    public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['corsFilter'] = [
            'class' => Cors::className()
        ];
        if (!\Yii::$app->request->isOptions) {
            $behaviors['authenticator'] = [
                'class' => HttpBearerAuth::className()
            ];
        }
        return $behaviors;
    }
}